<template>
  <div class="app-container">
    <my-header :title="title"></my-header>
    <my-goods v-for="item in list" :key="item.id" :goods="item"></my-goods>
    <my-footer :list="list"></my-footer>
  </div>
</template>

<script>
import MyHeader from "./components/MyHead";
import MyGoods from "./components/MyGoods";
import MyFooter from "./components/MyFooter";
export default {
  name: "App",
  components: {
    MyHeader,
    MyGoods,
    MyFooter,
  },
  data() {
    return {
      title: "购物车",
      list: [],
    };
  },
  async created() {
    // 在main.js中配置baseURL
    // 在App.vue中created时使用全局属性this.$http,请求/api/cart
    let res = await this.$http({ url: "/api/cart" });
    // console.log(res);
    this.list = res.data.list;
  },

  mounted() {},

  methods: {},
};
</script>

<style>
.app-container {
  margin: 40px 0 50px 0;
}
</style>